flag = 0
while flag == 0:
    num = int(input())
    if num != 0:
        dp = [1, 2, 4]
        i = 3
        if num <= 2:
            print(num)
        else:
            while i < num:
                dp.append(dp[i - 1] + dp[i - 2] + dp[i - 3])
                i += 1
                print(dp[- 1])
            else:
                flag = 1